<!-- Phan khai bao bien cuc bo-->
<?php
//echo "hi";

//Lay so dong tren mot danh sach
//error_reporting(ALL);
$v_limit_row = _CONST_NUMBER_OF_ROW_PER_LIST;
if(isset($_REQUEST['hdn_record_number_page'])){
	$v_limit_row = $_REQUEST['hdn_record_number_page'];
}
//Lay trang thu x
$v_page = 1;
if(isset($_REQUEST['hdn_page'])){
	$v_page=$_REQUEST['hdn_page'];	
}
$v_worktype = $_REQUEST['hdn_worktype']; 
if($v_worktype == "THAY_DOI_NGUOI_THU_LY"){
	$v_title_form = CONST_RECORD_SHARING_CHANGLE_TITLE;
}else{
	$v_title_form = CONST_RECORD_SHARING_TITLE;
}

$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
$v_staff_id = $_SESSION['staff_id'];

$v_recordtype_name = Get_text_from_array($_SESSION['recordtype'],'PK_RECORDTYPE','PK_RECORDTYPE','C_NAME',$v_recordtype_filter);
$v_handle_agency_id = $arr_single_recordtype['FK_HANDLE_AGENCY'];
$v_handler_id_list = Get_text_from_array($_SESSION['recordtype'],'PK_RECORDTYPE','PK_RECORDTYPE','FK_HANDLER_LIST',$v_recordtype_filter);
foreach($_SESSION['arr_all_unit'] as $v_agency)
	if($v_agency['id'] == $v_handle_agency_id)
		$v_handler_agency_name = $v_agency['name'];
//echo $v_handler_id_list;
//var_dump($_SESSION['arr_all_enduser']);
 
$arr_staff = get_arr_staff_in_list($v_handler_id_list);
//var_dump($arr_staff);
$v_record_code_list='';
for($row_index = 0;$row_index< $v_count;$row_index++){
	if ($row_index<$v_count-1)
		$v_record_code_list = $v_record_code_list . $arr_all_record[$row_index][0].", ";
	else
		$v_record_code_list = $v_record_code_list . $arr_all_record[$row_index][0];
}
$v_work_date = date("d/m/Y"); 
?>
<!--bang chua tieu de cua form-->
<table width="100%" cellpadding="0" cellspacing="0">
	<tr class="large_title">
		<td><?php echo $v_title_form; ?></td>
	</tr>
</table>
<!-- Bat cac phim: F12=true; Insert=false; Delete=false, ESC=true; Enter=true -->
<div id="hotkey" onKeyDown="javascript:process_hot_key(true,false,false,true,true);">
<!--bang chua cac text box de nhap du lieu-->
<table width="100%" class="form_table1">
	<col width="20%"><col width="60%"><col width="20%">
	<tr>
		<form action="index.php" method="post" name="f_record_update_status">
		<input type="hidden" name="fuseaction" value="" >
		<input type="hidden" name="hdn_record_id_list" value="<?php echo $v_record_id_list ?>" >
		<input type="hidden" name="hdn_recordtype_filter" value="<?php echo $v_recordtype_filter;?>">
		<input type="hidden" name="hdn_primary_handler_code" value="">
		<input type="hidden" name="hdn_primary_handler_id" value="">
		<input type="hidden" name="hdn_worktype_changle" value="<?php echo $v_worktype; ?>">
		<input type="hidden" name="hdn_handle_agency_id" value="<?php echo $v_handle_agency_id; ?>">
		<input type="hidden" name="hdn_recordtype_id" value="<?php echo $v_recordtype_id; ?>">
		<input type="hidden" name="hdn_handler_id_list" value="<?php echo $v_handler_id_list; ?>">
		<input type="hidden" name="hdn_handler_list_id" value="<?php echo $v_handler_list_id; ?>">
		<input type='hidden' name='hdn_page' value='<?php echo $v_page;?>'>
		<input type='hidden' name='hdn_record_number_page' value='<?php echo $v_limit_row;?>'>
	</tr>
	<tr>
	<tr>
		<td class="normal_label"><?php echo CONST_RECORD_TYPE_LABEL; ?></td>
		<td><?php echo $v_recordtype_name;?></td>
	</tr>
	<tr>
		<td class="normal_label"><?php echo CONST_LIST_RECORD_LABEL; ?></td>
		<td><?php echo $v_record_code_list;?></td>
	</tr>
	<tr>
		<td class="normal_label"><?php echo CONST_AGENCY_NAME_LABEL; ?></td>
		<td><?php echo $v_handler_agency_name;?></td>
	</tr>
	<tr>
		<td class="normal_label"><?php echo _CONST_WORK_DATE_LABEL?></td>
		<td>
			<input class="normal_date_textbox" name="txt_work_date" type="text" value="<?php echo $v_work_date; ?>" optional="true" isdate="true" message="<?php echo _CONST_WORK_DATE_MESSAGE;?>" onKeyDown="change_focus(document.forms(0),this)">
			<img src="<?php echo $_ISA_IMAGE_URL_PATH;?>calendar.gif" border="0" onclick="DoCal('<?php echo $_ISA_LIB_URL_PATH;?>isa-calendar/',document.forms(0).txt_work_date);" style="cursor:hand">
		</td>
	</tr>	

<!--chuongnlt begin-->
	<tr>
		<td class="normal_label"><?php echo CONST_PRIMARY_HANDLER_LABEL;?><small class="small_starmark">*</small></td>
		<td>
			<input name="txt_primary_handler"  readonly="true" type="text" class="normal_textbox" size="40" value="<?php echo $v_primary_handler_name; ?>"  message="<?php  echo CONST_PRIMARY_HANDLER_MESSAGE;?>" optional="<?php echo  CONST_PRIMARY_HANDLER_OPTIONAL;?>" onKeyDown=" change_focus(document.forms(0),this)">
			<img src="<? echo $_ISA_IMAGE_URL_PATH;?>find.gif" width="18" height="18" title="<?php echo  CONST_SHOW_CHOSICE_MAIN_HANLER?>" class="normal_image" onClick="show_dialog_all_item_onclick('index.php','DISPLAY_ALL_STAFF_BY_UNIT',document.forms(0).txt_primary_handler,document.forms(0).hdn_primary_handler_code,document.forms(0).hdn_primary_handler_id,document.forms(0).hdn_handle_agency_id.value,document.forms(0).hdn_handler_id_list.value);re_display_list_handler();document.forms(0).fuseaction.value='DISPLAY_SHARING_RECORD';">
		</td>
	</tr>
	<!--chuongnlt end-->

	<!--Danh sach nguoi phoi hop thu ly-->
	<tr style="display:<?php echo $v_dis;?> ">
		<td class="normal_label" colspan="2"><?php echo CONST_CO_HANDLER_LABEL;?></td>
	</tr>
	<tr id="tr_list_all_staff">
		<td colspan="5"class="normal_label"><?php echo Generate_handler_List($arr_staff,'0','3',$v_handler_list_id,'chk_handler_list_id','"tr_handler_name"','"rad_handler_name"'); ?></td>
	</tr>
</table>


<!--bang chua cac button-->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr><td>&nbsp;</td></tr>
	<tr align="center">


		<td><?php //nieuvv--170908--kiem tra them NSD co phai la nguoi tiep nhan hay khong?----
			if (($v_is_granted_update)||onegate_is_receiver_for_recordtype($v_staff_id,$v_recordtype_filter,$_SESSION["recordtype"])||onegate_is_handler_leader_for_recordtype($v_staff_id,$v_recordtype_filter,$_SESSION["recordtype"])||onegate_is_handler_leader_first_time_for_recordtype($v_staff_id,$v_recordtype_filter,$_SESSION["recordtype"])){

			?>
				<input type="button" name="btn_save"  class="normal_button" value="<?php echo _CONST_SAVE_BUTTON;?>" onClick="set_value_hidden(document.forms(0).hdn_worktype_changle,'<?php echo $v_worktype;?>');save_hidden_list_item_id(document.forms(0).hdn_handler_list_id,document.forms(0).chk_handler_list_id);btn_save_sharing_record_onclick('UPDATE_SHARING_RECORD');" onKeyDown = "change_focus(document.forms(0),this)"><?php
			}?><!--
			<input type="button" name="btn_back" class="normal_button" value="<?php echo _CONST_BACK_BUTTON;?>" onClick="btn_back_onclick('')" onKeyDown="change_focus(document.forms(0),this)">
			-->
		</td>
	</tr>
</table>					
</div>
</form>
<!--chuongnlt begin-->

<script>
function btn_save_sharing_record_onclick(p_fuseaction){
	if (verify(document.forms(0))){
		document.forms(0).fuseaction.value = p_fuseaction;
		document.forms(0).submit();
	}
}

</script>
<script>
function save_hidden_list_item_id(p_hdn_list,p_chk_obj){
	if (checkbox_value_to_list(p_chk_obj,",")!=""){
		p_hdn_list.value = checkbox_value_to_list(p_chk_obj,",");
//		alert(p_hdn_list.value);
	}
}

</script>
<script>
function set_value_hidden(obj,obj_value){
	obj.value = obj_value;
}
</script>

<!--chuongnlt end-->
